package com.spring.component.easyexcel.listener;


import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.fastjson.JSONObject;
import com.spring.component.easyexcel.DemoData;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class DemoDataListener extends AnalysisEventListener<DemoData> {

  @Override
  public void invoke(DemoData demoData, AnalysisContext analysisContext) {
    int row = analysisContext.readRowHolder().getRowIndex();
    int sheetNo = analysisContext.readSheetHolder().getSheetNo();
    String sheetName = analysisContext.readSheetHolder().getSheetName();
    log.info("读取到[{}]的第{}行记录：{}", sheetName, row, JSONObject.toJSONString(demoData));
  }

  @Override
  public void doAfterAllAnalysed(AnalysisContext analysisContext) {
    log.info("excel数据读取完成");

  }
}
